#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
using namespace std;
template <class T>
class SList {
private:
	T data;
	SList* next;
public:
	SList(T _data = 0) {
		data = _data;
		next = this;
	}
	SList(SList& s) {
		data = s.data;
		next = s.next;
	}
	void push_back(T _data) {
		SList* str = this;
		while (str->next != this) {
			str = str->next;
		}
		str->next = new SList(_data);
		str->next->next = this;
	}
	void dele_back() {
		if (this->next == this) {
			data = -1;
			cout << "list is empty" << endl;
			return;
		}
		SList* str = this;
		while (str->next->next != this) {
			str = str->next;
		}
		str->next = this;
	}
	SList* find_value(T _data) {
		SList* str = this;
		if (data == _data)return this;
		while (str->next) {
			str = str->next;
			if (str->data == _data)return str;
		}
	}
	void print() {
		SList* str = this->next;
		cout << data << " ";
		while (str != this) {
			cout << str->data << " ";
			str = str->next;
		}
		cout << endl;
	}
	void change(T _data) {
		data = _data;
	}
	int size() {
		SList* str = this;
		int i = 1;
		while (str->next != this) {
			str = str->next;
			i++;
		}
		return i;
	}
	void jos_del_print(int m,int k) {
		int i = 1;
		SList* str1 = this;
		while (k > 1) {
			str1 = str1->next;
			k--;
		}
		SList* str2 = nullptr;
		while (str1->size() != 1) {
			while (i != m) {
				str1 = str1->next;
				i++;
			}
			cout << str1->data << " ";
			str2 = str1;
			while (str2->next != str1) {
				str2 = str2->next;
			}
			str2->next = str1->next;
			str1 = str1->next;
			i = 1;
		}
		cout << str1->data << endl;
	}
};
int main() {
	SList<int> s1(1);
	int i = 0;
	int n = 0;
	cin >> n;
	for (i = 2; i <= n; i++) {
		s1.push_back(i);
	}
	s1.print();
	int m = 0;
	int k = 0;
	cin >> m>>k;
	s1.jos_del_print(m,k);
	return 0;
}